<?php

require_once 'base.php';

class MixuseumConfigAPI extends MiniappBase {
    // 获取博物馆基础配置列表
    public function getList() {
        try {
            // 获取基础配置
            $sql = "SELECT * FROM museum_config";
            $data = $this->db->fetchAll($sql);

            $new_data = [];
            foreach ($data as $config) {
                $new_data[$config['config_key']] = $config;
            }

            $this->success($new_data, '获取基础配置成功');
        } catch (Exception $e) {
            $this->error('获取基础配置失败');
        }
    }
    
}

// 处理请求
$museum_config = new MixuseumConfigAPI();

$method = $_SERVER['REQUEST_METHOD'];
$action = $_GET['action'] ?? '';

switch ($method) {
    case 'GET':
        switch ($action) {
            case 'getList':
                $museum_config->getList();
                break;
            default:
                $museum_config->error('无效的操作');
        }
        break;
    default:
        $museum_config->error('无效的操作');
}

?>
